//
//  SYTingKeXinDeView.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/4/23.
//  Copyright © 2019年 SanYi. All rights reserved.
//

#import "SYTingKeXinDeView.h"
#import "SYAttendLectureTableViewCell.h"
#import "SYDetailsXinDeTableViewCell.h"
@interface SYTingKeXinDeView () <UITableViewDelegate,UITableViewDataSource>

@property (strong, nonatomic) UITableView *curTableView;// 表


@end


@implementation SYTingKeXinDeView


- (instancetype)init {
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor colorWithHexString:@"#EEEEEE"];
        [self initSubView];
    }
    return self;
}

- (void)initSubView {
    [self addSubview:self.curTableView];
    [self.curTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self);
        make.left.equalTo(self.mas_left).offset(14);
        make.right.equalTo(self.mas_right).offset(-14);
    }];
    
    
}
#pragma mark - tab
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 20;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 1;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        SYAttendLectureTableViewCell *lectureCell = [tableView dequeueReusableCellWithIdentifier:@"SYAttendLectureTableViewCell" forIndexPath:indexPath];
        [lectureCell attendLectureTableDetailsType:SYDetailsTypeJiLu];//先这样传数据，等有了在换
        lectureCell.selectionStyle = UITableViewCellSelectionStyleNone;
        return lectureCell;
    } else {
        SYDetailsXinDeTableViewCell *detailsCell = [tableView dequeueReusableCellWithIdentifier:@"SYDetailsXinDeTableViewCell" forIndexPath:indexPath];
        detailsCell.selectionStyle = UITableViewCellSelectionStyleNone;
        [detailsCell detailsXinDeTableViewType:SYDetailsTypeXinDe];
        return detailsCell;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [UIView new];
    
    UIView *fgxView = [UIView new];
    fgxView.backgroundColor = [UIColor colorWithHexString:@"#CCCCCC"];
    [view addSubview:fgxView];
    [fgxView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view.mas_top).offset(0);
        make.left.equalTo(view.mas_left).offset(28);
        make.right.equalTo(view.mas_right).offset(-28);
        make.height.mas_equalTo(1);
    }];
    
    return view;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [UIView new];
    UIView *topView = [UIView new];
    topView.backgroundColor = [UIColor colorWithHexString:@"F8F8F8"];
    [view addSubview:topView];
    [topView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(view.mas_top).offset(0);
        make.left.equalTo(view.mas_left).offset(14);
        make.right.equalTo(view.mas_right).offset(-14);
        make.height.mas_equalTo(20);
    }];
    return view;
}
- (UITableView *)curTableView {
    if (!_curTableView) {
        _curTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStyleGrouped];
        
        _curTableView.delegate = self;
        _curTableView.dataSource = self;
        _curTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _curTableView.backgroundColor = [UIColor whiteColor];
        [_curTableView registerCellWithNIbNames:@[@"SYAttendLectureTableViewCell",@"SYDetailsXinDeTableViewCell"]];
    }
    return _curTableView;
}


@end
